﻿
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace TestDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;

            while (true)
            {
                a++;
                for (int i = 0; i < 10; i++)
                {
                    if (i == 3)
                        break;
                }

            }

            var u = DateTime.Now.ToString("G");
            // Test1();
            // Test2();
        }

        //private static void Test2()
        //{
        //    List<double> fit_time=null;
        //    List<double> fit_data = null;
        //    List<double> smooth_time = null;
        //    List<double> smooth_data = null;
        //    LinearRegression linearRegression = null;
        //   List<double> time=new List<double>();
        //    List<double> data = new List<double>();
        //    string fullPath = @"X:\Users\Administrator\Desktop\新建文件夹\raw.txt";
        //    using (StreamReader sr = new StreamReader(fullPath))
        //    {
        //        while (!sr.EndOfStream)
        //        {
        //            if (sr.ReadLine() == "降温曲线	改X轴	")
        //            {
        //                break;
        //            }
        //        }
        //        while (!sr.EndOfStream)
        //        {
        //            string line = sr.ReadLine();
        //            string[] parts = line.Split('	');
        //            double t = double.Parse(parts[0]);
        //            double v = double.Parse(parts[1]);
        //            time.Add(t);
        //            data.Add(v);
        //        }
        //    }
        //    //for (int i = 0; i < 1000; i++)
        //    //{
        //        MathUtils.Calibrate(time,
        //                          data,
        //                          0, 2e-3,
        //                          out  fit_time,
        //                          out  fit_data,
        //                          out  smooth_time,
        //                          out  smooth_data,
        //                           out  linearRegression,
        //                           null, null
        //                          );
        //        ////if(linearRegression.R2 >0.999)
        //        ////{
        //        ////    break;
        //        ////}
        //    //}
        //    string path = @"X:\Users\Administrator\Desktop\新建文件夹\fit.txt";   
        //    using (StreamWriter sw = new StreamWriter(path))
        //    {
        //        for (int i = 0; i < fit_time.Count; i++)
        //        {
        //            sw.WriteLine(string.Format("{0}\t{1}", fit_time[i], fit_data[i]));
        //        }
        //    }
        //}

        //private static void Test1()
        // {
        // Start TESTTYPE=TspVpn;Start_Flag=0;SectionID=TestSection_A;Json={"BranchA":4,"BranchB":4,"IM_A":0.1,"IM_B":-256.0,"VgeMeas":[12.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0],
        // "Start_Flag":0,"TESTTYPE":"TspVpn","TemperatureSensor":"INT"}
        //    var json = "{\"BranchA\":4,\"BranchB\":4,\"IM_A\":0.1,\"IM_B\":-256.0,\"VgeMeas\":[12.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0],\"Start_Flag\":0,\"TESTTYPE\":\"TspVpn\",\"TemperatureSensor\":\"INT\"}"; ;
        //    var mapJson = JsonNewtonsoft.FromJSON<Dictionary<string, object>>(json);
        //double[] imeasures = new double[2];
        //imeasures[0] = (double) mapJson["IM_A"];
        //imeasures[1] = (double) mapJson["IM_B"];
        //double[] ImeasureSet = imeasures;
        //var VGEmeasureSet = JsonConvert.DeserializeObject<double[]>(mapJson["VgeMeas"].ToString());


        //var json = "{\"Zone1_DUT\":0,\"BranchA\":4,\"BranchB\":4,\"IM_A\":0.1,\"IM_B\":-256.0,\"VgeMeas\":[15.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0],\"VgeHeat\":[15.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0,-256.0],\"PowerOP\":2,\"Ton_A\":2.0,\"Ton_B\":0.5,\"Toff_A\":3.0,\"Toff_B\":0.5,\"Iheat\":100.0,\"Operation\":0,\"TestMode\":\"IGBT\",\"SwitchFlow\":\"False\",\"Start_Flag\":0,\"TESTTYPE\":\"PCSec\"}";

        //var map = JsonNewtonsoft.FromJSON<Dictionary<string, object>>(json);

        //double[] imeasures = new double[2];
        //imeasures[0] = (double)map["IM_A"];
        //imeasures[1] = (double)map["IM_B"];

        //double iheatSet = (double)map["Iheat"];
        //double[] imeasure = imeasures;
        //double ton = (double)map["Ton_A"];
        //double toff = (double)map["Toff_A"];
        //var VgeHeat = JsonConvert.DeserializeObject<double[]>(map["VgeHeat"].ToString());
        //var VgeMeas = JsonConvert.DeserializeObject<double[]>(map["VgeMeas"].ToString());
        //double[] vGEHeat = VgeHeat;
        //double[] vGEMeasure = VgeMeas;
        //}


    }
}
